<?php

class Book_Form_Book extends Zend_Form
{

    public function init()
    {
        $this->setName('book');
        $this->setAttrib('enctype','multipart/form-data');
        $this->setMethod('post');
        
        $file = $this->createElement('file','file',array(
                                        'label' => 'Choose an Image',
                                    ));
        $file->addValidator('Extension', false, array('jpg', 'gif', 'png', 'jpeg'))
                ->addValidator('Size', false, 100000);

        $id = new Zend_Form_Element_Hidden('id');
        $id->addFilter('Int');
        
        
        $author = new Zend_Form_Element_Text('author');
        $author->setLabel('Author (*)')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty');
        
        $title = new Zend_Form_Element_Text('title');
        $title->setLabel('Title (*)')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty');
        
        $price = new Zend_Form_Element_Text('price');
        $price->setLabel('Price (*)')
                ->setRequired(true)                
                ->addValidator('Float')
                ->addValidator('NotEmpty');
        
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('id', 'submitbutton');        
        $this->addElements(array($id, $title, $author, $price, $file, $submit));
    }

}

